<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form>
        <label>
            姓：<input type="text" id="family-name">
        </label>
        <br>
        <label>
            名：<input type="text" id="given-name">
        </label>
        <br>
        <input type="button" value="点击" onclick="showName()">
    </form>
</body>

<script>
    function showName() {
        var familyName = document.getElementById("family-name").value;
        var giveName = document.getElementById("given-name").value;
        alert("姓名为："+familyName+giveName+"!");
    }
</script>
</html>